1. Field of the Invention
Embodiments of the present invention relate to computer graphics processing systems in general and, in particular, to graphics processing units (GPUs) that accept and process multiple, different types of texture maps as a related single set for three-dimensional scenes.
2. Description of the Related Art
Three-dimensional (3D or 3-D) models in modern video games use multiple textures to approach a realistic appearance in 3D scenes. A texture, sometimes called a texture map, is typically a table of color, transparency, material properties, surface orientations, or other features that can be digitally wrapped around or otherwise mapped to a 3D object. In video games, the textures used for a 3D model often include a diffuse color texture, a specular (shiny) color texture, a normal map, a transparency map, material index, and others. These textures are applied one at a time to a 3D model by storing the appropriate texture in memory and passing an address to the memory to a graphics processor unit (GPU).
FIG. 1 illustrates a prior art system for applying textures to an image with a graphics processor. In system 100, three-dimensional model 101 is stored in a memory for processing by GPU 113. Texture map 105, consisting of red (R) channel map 102, green (G) channel map 103, and blue (B) channel map 104, are stored in a memory for application onto the model.
Each of the channel maps is a generic N-dimensional table that happens to have hardware support for interpolation and filtering. The channel maps can be integer- or floating point-based depending upon the application. For example, diffuse texture map 105 is integer-based, all data within being of integer data type 109. The diffuse map has three integer values per texel, R, G, and B, representing the red, green, and blue color components. The three integer values for each texel follow one another in memory, i.e., are interleaved. That is, values in the table are stored as RGB, RGB, RGB, etc. Each 8-bit integer represents an amount of red color and is allowed values between and including 0 to 255. Taken with the G and B channels, the amount of colors represented by RGB texture map 105 is 256×256×256˜=over 16 millions colors. In alternative formats, an additional alpha A (transparency) channel is sometimes interleaved with the RGB values for the texel in an “RGBA” format. That is, values in the table are stored as RGBA, RGBA, RGBA, etc. This allows for a 4-byte memory alignment of texels for 8-bit channel textures. If the alpha channel is unused in the alternate format, it is sometimes wasted and called an “RGBX” format. In the exemplary embodiment, a memory address of texture map 105 is sent as a parameter in a function to the GPU for mapping to the 3D object.
After the colors of diffuse color texture map 105 are applied to 3D model 101, control is turned back from GPU 113 to the rendering application (i.e., the “user” of the GPU). The rendering application then passes specular (i.e., shiny) color RGB texture map 106 to GPU 113 with (an address of) an image storing the results of the first step. Like diffuse color texture map 105, Specular color texture map 106 is also an integer-based texture map consisting of three channels: RGB. The specular colors are applied to the 3D model to update the image.
After the diffuse and specular color textures are applied to the 3D model, a normal map can be used to update the image. A surface in which a light source is directly normal (i.e., orthogonal) to a surface is lit differently than one in which the light source is at an angle. Similarly, light sources at grazing angles off a surface with respect to the location of the virtual camera are lit differently.
Normal map 107 is passed as a parameter to GPU 113. Normal map 107 is floating point-based, represented by floating point data type 110 for all data in its tables. Each floating-point number in its X, Y, and Z tables represents a direction in space. The X channel map is a two-dimensional array of floating point numbers. Each 32-bit signed floating point number represents a magnitude in the X-direction that a unit vector leans, i.e., the X component of the unit vector. Y and Z channels represent Y and Z components of the unit vector, respectively. A memory address of each array is sent as a parameter to the GPU for processing to update the image.
After lighting is updated using the normal map, transparency/opacity is applied. Transparency map 108, an integer-based texture map, is represented in a single channel, sometimes called the “alpha channel.” The alpha channel is a single, two-dimensional array of integers. The greater the integer, the more opaque. The values typically represent ‘one-minus’ the transparency.
After the four texture maps are applied to the 3D model, a relatively realistic-looking image is ready for presentation to an end user in a video game, computer aided design (CAD) image, or other three-dimensional virtual environment. Image 111 is the result of the GPU's application of the texture maps.
In other prior art methods, the central processing unit (CPU) passes the addresses of all textures to the GPU, specifies shader code and geometry for the GPU, and then hands over control to the GPU. The GPU draws the geometry, applying the specified shader for each pixel that covers that geometry. The shader accesses the textures as local variables of the applicable array type (e.g., 1-, 2-, or 3-dimensional arrays) with interpolation support. The shader uses those textures to create the end product, even applying a channel or channels of a texture multiple times. For example, the shader can re-use the R component of the diffuse channel as a reflectivity value. However, texture interpolation is wastefully repeated several times.
Although graphics processors and rendering techniques have improved by leaps and bounds in the past few decades, notably in mass produced, consumer-grade video game hardware, there is an ever-present need in the art for faster and more efficient 3D rendering.